<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <title>Example</title>
</head>

<body>
  <button id="back">Back</button>
  <button id="forward">Forward</button>
  <button id="go">Go</button>

  <script type="text/javascript">
    var buttons = document.getElementsByTagName('button');
    for (var i = 0; i < buttons.length; i++) {
      buttons[i].onclick = handleButtonPress;
    }

    function handleButtonPress(e) {
      if (e.target.id == "back") {
        window.history.back();
      } else if (e.target.id == "forward") {
        window.history.forward();
      } else if (e.target.id == "go") {
        window.history.go("http://apress.com");
      }
    }
  </script>
</body>

</html>
